/**
 * 视频控制器
 */
angular
.module('myApp')
.controller('itemVideoController', function($scope, $routeParams, classManager) {

  $scope.videoClicked = function(index) {
    if ($scope.current != index) {
      var video = document.getElementById('video-'+$scope.current);

      if (!video.paused) {
        video.pause();
      }

      $scope.current = index;
    }
  }

  classManager.getCourse($routeParams.id, 3)
    .then(function(data) {
      $scope.data = data;
    });

  $scope.$watch('data', function(value) {
    if (angular.isDefined(value) && (value.length > 0)) {
      $scope.current = 0;
    }
  });
});
 